home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL2.LZH / SIDEWAYS.PAS < prev    next >
Pascal/Delphi Source File  |  1984-08-28  |  4KB  |  111 lines

  1. {$line+,$symtab-,$linesize:131,$pagesize:65}program sideways(input,output,infile);
  2.  
  3. {COPYRIGHT @ 1983
  4.       Jim Holtman
  5.       35 Dogwood Trail
  6.       Randolph, NJ 07869
  7.       (201) 361-3396}
  8.  
  9. {This program will print the `infile' sideways on an EPSON MX-80 Printer.
  10.  It makes use of the characters in the PC's ROM for the graphics mode of
  11.  the CRT. The characters in the file are `looked up' and then the graphics
  12.  mode of the printer is used for output.}
  13.  
  14. { The DEBUG statements will output on the CRT the current line being printed.
  15.   The line will appear vertically. }
  16.  
  17. type
  18.     vstr = super array[0..*] of char;
  19.     CHAR_PER_LINE = 0..2000;{Maximum input line size}
  20.  
  21. const
  22.     EOF = chr(26);{TEXT EOF character}
  23.     EOL = chr(13);
  24.     TAB = chr(9);{expand TABs}
  25.     IGNORE = [chr(0)..chr(8),chr(10)..chr(#1f),chr(#80)..chr(#FF)];
  26.     MAX_LINES = 48;{Lines/Page}
  27.     SPACES_PER_LINE = 2;{2/72th inch space between lines}
  28.     SPACES_PER_LETTER = 8;{DOT size of characters}
  29.  
  30. var
  31.     lptr : array[1..MAX_LINES] of ^vstr; {input lines}
  32.     inbuf : array[CHAR_PER_LINE] of char;
  33.     linesize : CHAR_PER_LINE;
  34.     indx : 0..MAX_LINES;
  35.     line : 0..MAX_LINES+1;
  36.     infile : file of char;
  37.     printer : text;
  38.     col : CHAR_PER_LINE;
  39.     pchar : integer;
  40.     ichar : 0..7;
  41.     max : CHAR_PER_LINE;
  42.     rom : ads of array[0..32000] of char;
  43.  
  44. value
  45.   {NOTE!!!!
  46.      The following declarations define the segment and offset values
  47.      for the characters in the PC version of the ROM. For the XT, check
  48.      the TECH MANUAL for the correct values.}
  49.  
  50.     rom.s := #F000; {address of the CRT character generation}
  51.     rom.r := #FA6E; {matrix in the ROM -- for non-XT versions of PC}
  52.  
  53. begin
  54.     assign(printer,'lpt1:');            {open the printer}
  55.     rewrite(printer);
  56.     reset(infile);
  57.     repeat
  58. max := 0;
  59. linesize := 0;
  60. line := 1;
  61. while (line <= MAX_LINES) do begin
  62.     if infile^ = EOL then begin {check for End-of-Line}
  63. new(lptr[line],linesize+1);  {allocate string storage}
  64. movel(adr inbuf[0],adr lptr[line]^[0],wrd(linesize+1)); {save}
  65. if linesize > max then max := linesize;
  66. linesize := 0;
  67. line := line+1;
  68. get(infile);
  69. writeln(output,'<<');   {--DEBUG--}
  70. cycle;
  71.     end;
  72.     if infile^ = EOF then break;
  73.     if not(infile^ in IGNORE) then begin
  74. if infile^ = TAB then
  75.     repeat{Expand TABs}
  76. linesize := linesize+1;
  77. inbuf[linesize] := ' ';
  78.     until (linesize mod 8) = 0
  79. else begin
  80.     linesize := linesize+1;
  81.     inbuf[linesize] := infile^;
  82. end;
  83. write(output,infile^);{--DEBUG--}
  84.     end;
  85.     get(infile);
  86. end;
  87. writeln(output,'line=',line,' max=',max);  {--DEBUG--}
  88. if infile^ <> EOF then line := MAX_LINES
  89. else line := line-1;
  90. for col := 1 to max do begin{Output collected lines}
  91.     write(printer,chr(27)*'A'*chr(SPACES_PER_LETTER)*chr(27)*'K',
  92.      chr((line*(8+SPACES_PER_LINE)) mod 256),
  93.      chr((line*(8+SPACES_PER_LINE)) div 256));
  94.     for indx := line downto 1 do begin{Scan next column}
  95. {if column pointer is larger than string, output BLANK}
  96. if col > upper(lptr[indx]^) then pchar := ord(' ')
  97. else pchar := ord(lptr[indx]^[col]);
  98. write(output,chr(pchar));  {--DEBUG--}
  99. pchar := pchar*8;
  100. for ichar := 7 downto 0 do  {Pickup character, a line at a time, }
  101.     write(printer,rom^[pchar+ichar]); {from ROM}
  102. for ichar := 1 to SPACES_PER_LINE do write(printer,chr(0));
  103.     end;
  104.     writeln(printer);
  105.     writeln(output);{--DEBUG--}
  106. end;
  107. for indx := 1 to line do dispose(lptr[indx]);  {Free up space on HEAP}
  108. page(printer);
  109.     until infile^ = EOF;
  110. end.
  111.